package com.bobi.tfca.model.vo;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.bobi.tfca.model.entity.AuditEntity;
import com.bobi.tfca.model.enums.AuditStatusEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author 李文发
 * @date 2024/4/17
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "审核")
public class AuditVO implements Serializable {

    @Serial
    private static final long serialVersionUID = 6213499239118589772L;

    @ApiModelProperty(value = "审核id")
    // 审核id
    private Integer auditId;
    @ApiModelProperty(value = "类型")
    // 类型
    private Integer category;
    @ApiModelProperty(value = "具体类别")
    // 具体类别
    private Integer subType;
    @ApiModelProperty(value = "申请时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    // 申请时间
    private LocalDateTime applyTime;
    @ApiModelProperty(value = "具体项id")
    // 具体项id
    private Integer itemId;
    @ApiModelProperty(value = "审核者id")
    // 审核者id
    private Integer auditorId;
    @ApiModelProperty(value = "是否通过（0：未通过，1：通过）")
    // 是否通过（0：未通过，1：通过）
    private String auditStatus;
    @ApiModelProperty(value = "具体项名称")
    private String itemName;
    @ApiModelProperty(value = "审核人姓名")
    private String auditorName;

    public static AuditVO ofAuditEntity(AuditEntity auditEntity) {
        AuditVO auditVO = BeanUtil.copyProperties(auditEntity, AuditVO.class, "auditStatus");
        AuditStatusEnum status = AuditStatusEnum.getStatusByCode(auditEntity.getAuditStatus());
        auditVO.setAuditStatus(status.getDesc());
        return auditVO;
    }
}
